package com.mpush.core.chat;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.mpush.api.chat.ChatMessageDto;
import com.mpush.netty.http.HttpCallback;

import io.netty.handler.codec.http.HttpResponse;

public class ChatMessageHttpCallback implements HttpCallback {
	
	private static final Logger LOGGER = LoggerFactory.getLogger(ChatMessageHttpCallback.class);

	private ChatMessageDto chatMessageDto;
	
	public ChatMessageHttpCallback(ChatMessageDto chatMessageDto) {
		this.chatMessageDto=chatMessageDto;
	}

	@Override
	public void onResponse(HttpResponse response) {
		LOGGER.info("send chat request success end chatMessageDto={},response={}", chatMessageDto,response);
	}

	@Override
	public void onFailure(int statusCode, String reasonPhrase) {
		LOGGER.warn("send chat request failure end chatMessageDto={}, response={}:{}", chatMessageDto, statusCode ,reasonPhrase);
	}

	@Override
	public void onException(Throwable throwable) {
		 LOGGER.error("send chat request ex end chatMessageDto={}, response={}, exception={}", chatMessageDto, 502, throwable);

	}

	@Override
	public void onTimeout() {
		LOGGER.warn("send chat request timeout end chatMessageDto={}, response={}", chatMessageDto, 408);
	}

	@Override
	public boolean onRedirect(HttpResponse response) {
		return false;
	}

}
